# -*- coding: utf-8 -*-
"""
Created on Tue Sep 28 18:19:22 2021

@author: Administrator
"""
from skimage import data,util
from matplotlib import pyplot as plt
from scipy import ndimage
img=data.coffee()[:,:,0]
pepper_img=util.random_noise(img,mode='pepper',seed=None,clip=True)
salt_img=util.random_noise(img,mode='pepper',seed=None,clip=True)
n=3
max_img=ndimage.maximum_filter(pepper_img,(n,n))
min_img=ndimage.maximum_filter(pepper_img,(n,n))
plt.figure()
plt.imshow(img,cmap='gray')
plt.figure()
plt.imshow(pepper_img,cmap='gray')
plt.figure()
plt.imshow(salt_img,cmap='gray')
plt.figure()
plt.imshow(max_img,cmap='gray')
plt.figure()
plt.imshow(min_img,cmap='gray')    


